Skip to content

FIX: execution and doc failures from the Anaconda 2026.07 cache build (closes #182)#183

Merged
mmcky merged 1 commit into
mainfrom
fix/182-execution-and-doc-failures
Jul 20, 2026
Merged

FIX: execution and doc failures from the Anaconda 2026.07 cache build (closes #182)#183
mmcky merged 1 commit into
mainfrom
fix/182-execution-and-doc-failures

Conversation

@mmcky

@mmcky mmcky commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Resolves the four failures reported in #182. All four are target-side defects — the English source is healthy in every case, so none of these is an upstream backport.

The four fixes

likelihood_bayes — execution break. The font block called mpl.font_manager.fontManager and plt.rcParams before import matplotlib.pyplot as plt. Newer matplotlib no longer imports font_manager as a side effect of import matplotlib, so this raised AttributeError — and would have raised NameError on plt regardless. Moved the pyplot import above both uses. I audited the font block across all 69 lectures: this is the only file with either ordering hazard.

kalman_2 — execution break. A .text() annotation drew the covariance matrix with \begin{bmatrix}, which matplotlib mathtext cannot render — mathtext supports no LaTeX environments at all. Rewritten as \left[ \substack{...} \right] with \; as the column separator instead of &, which renders an equivalent bracketed 2×2 matrix and was verified by rendering it with real formatted values. This keeps the drop-usetex standard from #22 intact with no loss of information, so no exception to that standard is needed. The lecture's other \begin{bmatrix} uses are inside {math} blocks, rendered by MathJax in the browser, and were never at risk.

Worth noting for future sweeps: this site is invisible to a naive grep, because the braces are .format()-escaped as \begin{{bmatrix}}.

sir_model — doc error. The header directive had lost its argument: ```{raw} instead of ```{raw} jupyter. The other 50 lectures carrying this directive kept theirs.

ak_aiyagari — doc error, with a larger cause than #182 diagnosed. The issue recommended restoring a single H1. That would have papered over the actual bug. The file carried a stray fence immediately after the frontmatter, followed by a duplicated copy of the original frontmatter, plus a doubled closing fence at EOF. The stray opener ran to line 56, swallowing both the H1 title and the _admonition/gpu.md include — which is what produced the 13 "headings start at H2" warnings. Restoring an H1 alone would have left the include broken.

Removed both strays. The file's fence structure now matches the English source exactly (122 fences, balanced). The translation.title field was also corrupt — it read V, σ, μ, which is a Python tuple-unpacking line from deep inside a code cell in the source — and has been set to the lecture title.

Provenance

ak_aiyagari's corruption was introduced by the resync in #103. Before it (a664481) the file had 120 fences and was balanced; after (17b5b98) it had 124 with both strays present. The engine emitted its new translation: frontmatter, then an opening fence, then the entire original document verbatim, then a closing fence at EOF — it wrapped the document body in a code block. The corrupt translation.title points at the same root cause: the engine failed to parse this file's structure and fell back to a degraded path that mis-derived the title too.

This warrants an engine issue against action-translation; it is not covered by the existing #107/#115/#116/#117 set. Same for the {raw} argument stripping.

Verification

  • Fence balance now matches the English source exactly; an edition-wide sweep found no other unbalanced file, and a fleet sweep across all edition clones found none either.
  • code-cell counts match the English source for all four files.
  • The kalman_2 replacement was rendered with real formatted values to confirm it produces a correct bracketed matrix, rather than only checking that it parses (\substack with & parses but renders the ampersand literally — that trap is why).
  • Trailing newlines present on all four files.

What is not verified: none of this has been cold-executed. Per QuantEcon/meta#340 this repo's ci.yml sphinx-tojupyter step lacks -n -W, so a green build here is weak evidence for the two execution fixes. See the note below.

On build parity — deliberately not in this PR

Comparing ci.yml against the source repo lecture-python.myst confirms meta#340 and widens it. The source's sphinx-tojupyter step runs -n -W --keep-going; this repo's runs with no flags. The source also has a "Clear stale Sphinx environment" step and execution-report artifact uploads for the notebook and LaTeX builds that this repo lacks, so when that step does fail here there is no traceback artifact to read.

I have kept that out of this PR on purpose. Turning on -n -W will surface every remaining latent failure in the edition at once — and there almost certainly are some, since the cache build that produced #182 reused old-environment cache for roughly 15 unchanged lectures that were never re-tested. Folding it in here would likely turn this PR red for reasons unrelated to its own fixes. Content first, then the safety flag as its own PR that is expected to surface more.

Closes #182

🤖 Generated with Claude Code

Resolves the four failures reported in #182. All four are target-side
defects; the English source is healthy in every case.

likelihood_bayes — the font block called `mpl.font_manager.fontManager`
and `plt.rcParams` before `import matplotlib.pyplot as plt`. Newer
matplotlib no longer imports `font_manager` as a side effect of
`import matplotlib`, so this raised AttributeError (and would have
raised NameError on `plt`). Moved the pyplot import above both uses.
An audit of the font block across all 69 lectures found this the only
file with either ordering hazard.

kalman_2 — a `.text()` annotation drew the covariance matrix with
`\begin{bmatrix}`, which matplotlib mathtext cannot render (it supports
no LaTeX environments). Rewritten as `\left[ \substack{...} \right]`,
which renders an equivalent bracketed 2x2 matrix under mathtext, using
`\;` as the column separator rather than `&`. This keeps the
drop-usetex standard from #22 intact with no loss of information.
The lecture's other `\begin{bmatrix}` uses are inside `{math}` blocks,
rendered by MathJax, and are unaffected.

sir_model — the header directive had lost its argument: `{raw}` instead
of `{raw} jupyter`. The other 50 lectures carrying this directive kept
theirs.

ak_aiyagari — the file carried a stray fence at line 38 followed by a
duplicated copy of the original frontmatter, and a doubled closing
fence at EOF. The stray opener ran to line 56, swallowing both the H1
title and the `_admonition/gpu.md` include, which is what produced the
13 "headings start at H2" warnings. Removed both strays; the file's
fence structure now matches the English source exactly (122). The
`translation.title` field was also corrupt ("V, σ, μ") and has been set
to the lecture title. An edition-wide sweep found no other file with
unbalanced fences.

The last two are content corruption introduced in translation and
warrant engine issues against action-translation; they are not covered
by the existing #107/#115/#116/#117 set.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 20, 2026 00:50
@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for astonishing-narwhal-a8fc64 failed.

Name Link
🔨 Latest commit 0f7d6cc
🔍 Latest deploy log https://app.netlify.com/projects/astonishing-narwhal-a8fc64/deploys/6a5d70dcb555b10008d317d2

@netlify

netlify Bot commented Jul 20, 2026

Copy link
Copy Markdown

Deploy Preview for astonishing-narwhal-a8fc64 failed.

Name Link
🔨 Latest commit 0f7d6cc
🔍 Latest deploy log https://app.netlify.com/projects/astonishing-narwhal-a8fc64/deploys/6a5d70dcb555b10008d317d2

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes four lecture-specific regressions in the zh-cn edition that caused execution and documentation build failures in the Anaconda 2026.07 cache build (per #182), without requiring upstream (English) backports.

Changes:

  • Fixes a MyST {raw} directive that was missing its required jupyter argument (sir_model).
  • Fixes Matplotlib import ordering so font setup can safely use mpl.font_manager and plt.rcParams (likelihood_bayes).
  • Replaces an unsupported MathText LaTeX environment (\begin{bmatrix}...\end{bmatrix}) with a MathText-compatible bracketed 2×2 matrix rendering (kalman_2).
  • Repairs corrupted fencing/frontmatter and corrects translation.title in the lecture header (ak_aiyagari).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
lectures/sir_model.md Restores the {raw} jupyter directive argument to fix a doc build error.
lectures/likelihood_bayes.md Reorders Matplotlib imports so font configuration and plt.rcParams usage doesn’t fail at runtime.
lectures/kalman_2.md Rewrites a covariance annotation to avoid unsupported MathText LaTeX environments.
lectures/ak_aiyagari.md Removes stray/duplicated fences/frontmatter and fixes the corrupted translation.title field.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

Copy link
Copy Markdown

@github-actions
github-actions Bot temporarily deployed to pull request July 20, 2026 03:13 Inactive
@mmcky
mmcky merged commit ebdf378 into main Jul 20, 2026
4 of 8 checks passed
@mmcky
mmcky deleted the fix/182-execution-and-doc-failures branch July 20, 2026 03:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix execution + doc failures surfaced by the Anaconda 2026.07 cache build (kalman_2, likelihood_bayes, sir_model, ak_aiyagari)

2 participants